package com.dong.rabbitmq.work;

import com.dong.rabbitmq.utils.RabbitMqUtil;
import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

/**
 * 工作线程01（相当于以前的）
 * @author dongjian
 */
public class WorkConsumer01 {

    public static final String QUEUE_NAME = "hello";

    public static void main(String[] args) throws Exception{

        Channel channel = RabbitMqUtil.getChannel();

        DeliverCallback deliverCallback = (consumerTag, message) -> {
            System.out.println("消息接收:" + new String(message.getBody()));
        };

        CancelCallback cancelCallback = consumerTag -> {
            System.out.println(consumerTag + "消费者取消接收消费接口回调逻辑");
        };
        System.out.println("C2等待接收消息......");
        // 消费消息
        channel.basicConsume(QUEUE_NAME, true, deliverCallback,cancelCallback);
    }
}
